<%-- 
    Document   : ResultViewForm
    Created on : Jan 10, 2012, 12:37:23 AM
    Author     : Priyanka
--%>

<%@page import="java.util.Collection"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.ArrayList"%>
<%@page import="cassys.datatransferobjects.ResultDTO"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>

<br/>
<table>
    <tr>
        <td>
            <img src="<s:url value="/img/icons/chart_big.png"/>"> 
        </td>
        <td>
            <span class="title">
                Student results
            </span>
        </td>
    </tr>
</table>
<br/><br/>



<table border="2" class="tablesorter" style="width:600px">
    <thead>
        <tr>
            <th>Student ID</th>
            <th>Student Name</th>
            <th>Module Code</th>
            <th>Detailed Evaluation</th>
            <th>Peerevaluation Mark</th>
            <th>Mark</th>
        </tr>    
    </thead>
    <tbody>
        <s:iterator value="results">


            <tr>
                <td><s:property value="student"/></td>
                <td><s:property value="studentname"/></td>
                <td><s:property value="moduleCode"/></td>
                <td>
                    <table>
                        <s:iterator value="evaluationItemsMap" var="items"> 
                            <tr>
                                <td>${items.key}</td>
                                <td><s:property value="value"/></td>
                            </tr>
                        </s:iterator>
                    </table>

                </td>
                <td><s:property value="peerevaluationTotal"/></td>
                <td style="background-color:#EEE;"><b><s:property value="evaluationTotal"/></b></td>


            </tr>

        </s:iterator> 
    </tbody>
</table>  







<script type="text/javascript" src="<s:url value="/js/jqplot.plugins/jqplot.pieRenderer.min.js"/>"></script>
<script type="text/javascript" src="<s:url value="/js/jqplot.plugins/jqplot.donutRenderer.min.js"/>"></script>
<script type="text/javascript" src="<s:url value="/js/jqplot.plugins/jqplot.barRenderer.min.js"/>"></script>
<script type="text/javascript" src="<s:url value="/js/jqplot.plugins/jqplot.categoryAxisRenderer.min.js"/>"></script>
<script type="text/javascript" src="<s:url value="/js/jqplot.plugins/jqplot.cursor.min.js"/>"></script>
<script type="text/javascript" src="<s:url value="/js/jqplot.plugins/jqplot.highlighter.min.js"/>"></script>
<script type="text/javascript" src="<s:url value="/js/jqplot.plugins/jqplot.dateAxisRenderer.min.js"/>"></script>

<script type="text/javascript">
    
   
    
    
    
    $(function() {
            
    
    var data = [
    <%

        ArrayList<ResultDTO> results = (ArrayList<ResultDTO>) request.getAttribute("results");
        HashMap<Double, Integer> grades = new HashMap<Double, Integer>();

        for (ResultDTO result : results) {
            if (grades.containsKey(result.getEvaluationTotal())) {
                Integer temp = grades.get(result.getEvaluationTotal()) + 1;
                grades.remove(result.getEvaluationTotal());
                grades.put(result.getEvaluationTotal(), temp);
            } else {
                grades.put(result.getEvaluationTotal(), 1);
            }
        }

        int i = 0;
        Object[] count = new Integer[grades.values().size()];
        count = grades.values().toArray();
        for (Double grade : grades.keySet()) {
            if (i != 0)
                out.print(",");
            out.print("['" + grade + "', " + count[i] + "]");
            
            i++;
        }

    %>            
        ];
        var plot2 = jQuery.jqplot ('chart2', [data], {
            seriesColors: [ "#444", "#DF0174", "#AAA", "#AA0174", "#330114", "#958c12",
                "#953579", "#4b5de4", "#d8b83f", "#ff5800", "#0085cc"],
            seriesDefaults: {
                renderer: jQuery.jqplot.PieRenderer, 
                rendererOptions: {
                    // Turn off filling of slices.
                    fill: false,
                    showDataLabels: true, 
                    // Add a margin to seperate the slices.
                    sliceMargin: 10, 
                    // stroke the slices with a little thicker line.
                    lineWidth: 7
                }
            }, 
            legend: { show:true, location: 'e' }
        });	
            
            
            
            
            
       
		  
    });
	
	
</script>
<div id="chart2" style="height:300px;width:500px; "></div>

